package com.kzz.dialoglibraries.dialog;


import android.app.Dialog;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;

/**
 * Created By kzz on 2023/8/23
 * Describe:
 */
public class NoDoubleUtils {

    private static long MIN_CLICK_DELAY_TIME = 800;
    private static long lastClickTime = 0;


    public static void show(Dialog dialog) {
        long curTime = System.currentTimeMillis();
        if (curTime - lastClickTime > MIN_CLICK_DELAY_TIME) { //只有大于才会走逻辑
            lastClickTime = curTime;
            dialog.show();
        }
    }

    public static void show(DialogFragment dialogFragment, @NonNull FragmentManager manager, @Nullable String tag) {
        long curTime = System.currentTimeMillis();
        if (curTime - lastClickTime > MIN_CLICK_DELAY_TIME) { //只有大于才会走逻辑
            lastClickTime = curTime;
            dialogFragment.show(manager,tag);
        }
    }
}
